﻿using System;
using System.Windows.Forms;

namespace InputHandlers.KeyboardHandling
{
    public class ExtendedToggleKey : ToggleKey
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ToggleKey"/> class with the key definition.
        /// The only only allowed keys are 'Alt', 'Control' and 'Shift'.
        /// </summary>
        /// <param name="keyDefinition">Key definition.</param>
        /// <param name="operationToTake">An operation to take when requesting to verify the validity of an input against this key-definition.</param>
        /// <param name="isOn">Whether the key is started as toggled on.</param>
        public ExtendedToggleKey(Keys keyDefinition, Action operationToTake, bool isOn = false)
            : base(keyDefinition, operationToTake, isOn)
        {
            if (keyDefinition != Keys.Alt && keyDefinition != Keys.Control && keyDefinition != Keys.Shift)
            {
                throw new ArgumentException("'ExtendedToggleKey' maintains only Alt, Control and Shift keys.");
            }
        }

        public override bool CheckContained(Keys inputKey)
        {
            return (inputKey & KeyDefinition) != Keys.None;
        }
    }
}

